package com.example.aliyunsms.constant;
import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * Created by IntelliJ IDEA2022.3.2
 * @Author: Tenghw
 * @Date: 2023/04/04  22:04
 * @Description: 阿里云云通信的一些基本信息
 */
@Data
@Component
@PropertySource("classpath:application-dev1.yml")//这行注释掉也能读取到配置
@ConfigurationProperties(prefix = "aliyun.sms")
public class SmsContant implements InitializingBean {

    public String regionId;
    private String keyId;
    private String keySecret;
    private String templateCode;
    private String signName;


    public static String REGION_Id;
    public static String KEY_ID;
    public static String KEY_SECRET;
    public static String TEMPLATE_CODE;
    public static String SIGN_NAME;
    // 短信API产品名称（固定，无需修改）
    public final static String PRODUCT="Dysmsapi";
    // 短信API产品域名（固定，无需修改）
    public final static String DOMAIN="dysmsapi.aliyuncs.com";



    //当私有成员被赋值后，此方法自动被调用，从而初始化public常量
    @Override
    public void afterPropertiesSet() throws Exception {
        REGION_Id = regionId;
        KEY_ID = keyId;
        KEY_SECRET = keySecret;
        TEMPLATE_CODE = templateCode;
        SIGN_NAME = signName;
    }
}
